package interview;

public class interview_16_17 {
    public int maxSubArray(int[] nums) {
        int len=nums.length;
        if(len==0) return 0;
        int left=0;
        int right=0;
        int tmpsum=0;
        int sum=nums[0];
        while(right<len){
            tmpsum+=nums[right];
            sum=Math.max(sum,tmpsum);
            if(tmpsum>0){
                right++;

            }else{
                left=++right;
                tmpsum=0;
            }
        }
        return sum;
    }
}
